<?php
//微信用户相关

namespace App\Http\Controllers;

use App\Models\ConfigModel;
use App\Models\OperateModel;
use App\Repositories\StatisticsRepository;
use Illuminate\Http\Request;
use App\Http\Controllers\BaseController;
use App\Traits\BaseHttp;

class StatisticsController extends BaseController
{

    /**
     * @param StatisticsRepository $statisticsRepository
     * @return \Illuminate\Http\JsonResponse
     */
    public function getTopStatistics (StatisticsRepository $statisticsRepository)
    {
        $statisticsData = @$statisticsRepository->getTopStatistics();
        return $this->success($statisticsData);
    }

    public function test ()
    {
        echo 'test';
    }

    /**
     * @param Request $request
     * @param StatisticsRepository $statisticsRepository
     * @return \Illuminate\Http\JsonResponse
     */
    public function getChartStatistics (Request $request, StatisticsRepository $statisticsRepository)
    {
        $type = $request->type;
        $chartType = $request->chart_type;
        $statisticsData = @$statisticsRepository->getChartStatistics($type, $chartType);
        return $this->success($statisticsData);
    }

    /**
     * @param Request $request
     * @param StatisticsRepository $statisticsRepository
     * @return \Illuminate\Http\JsonResponse
     */
    public function getMonthRate (Request $request, StatisticsRepository $statisticsRepository)
    {
        $data = @$statisticsRepository->getMonthRate();
        return $this->success($data);
    }

    /**
     * @param Request $request
     * @param StatisticsRepository $statisticsRepository
     * @return \Illuminate\Http\JsonResponse
     */
    public function getMoneyRatePercent (Request $request, StatisticsRepository $statisticsRepository)
    {
        $data = @$statisticsRepository->getRatePercent();
        return $this->success($data);
    }
}
